package com.piao.springboot_mybatis.service;

import com.piao.springboot_mybatis.entity.Word;
//import com.piao.springboot_mybatis.mapper.WordMapper;//注解版
import com.piao.springboot_mybatis.mapper.WordMapper;
import com.piao.springboot_mybatis.mapper.WordMapper2;//XML文件版
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WordServiceImpl implements WordService {

    //注入Mapper接口对象   @Resource默认优先按照名称装配/@Autowired默认按类型装配
    @Resource
    WordMapper2 wordMapper2;

    @Resource
    WordMapper wordMapper;

    @Override
    public void insertWord(Word word) {
        wordMapper2.insertWord(word);
    }

    @Override
    public void deleteWordById(Integer id) {
        wordMapper2.deleteWordById(id);
    }

    @Override
    public void UpdateWordById(Integer id, String english, String chinese) {
        wordMapper2.UpdateWordById(id, english, chinese);
    }


    @Override
    public Word getWordById(Integer id) {
        return wordMapper2.getWordById(id);
    }

    @Override
    public List<Word> getAllWord() {
        return wordMapper2.getAllWord();
    }
}
